<?php

namespace App\Request\Report;

use App\Request\BaseCommonRequest;
use Hyperf\Context\Context;
use Hyperf\Validation\Request\FormRequest;

class TipOffCreateRequest extends BaseCommonRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'user_id' => 'required',
            'user_reason' => 'required',
            'from_page' => 'required|in:1,2,3,4',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        $language = Context::get('language');
        if ($language == 'zh-zn') {
            return [
                'user_id.required' => '举报对象不能为空',
                'user_reason.required' => '举报类型不能为空',
                'from_page.required' => '举报来源不能为空',
                'from_page.in' => '举报来源不正确',
            ];
        } elseif ($language == 'zh-hk') {
            return [
                'user_id.required' => '檢舉對象不得為空',
                'user_reason.required' => '檢舉類型不得為空',
                'from_page.required' => '檢舉來源不得為空',
                'from_page.in' => '檢舉來源不正確',
            ];
        } else {
            return [
                'user_id.required' => 'Reported user cannot be empty',
                'user_reason.required' => 'Report type cannot be empty',
                'from_page.required' => 'Report source cannot be empty',
                'from_page.in' => 'Report source is incorrect',
            ];
        }

    }


}